Repository navigation
Conversation
…elay For a logged-in user, OpenCode now calls only the model in the setup agent config, through the loopback proxy and the gonfalon model relay at /internal/ldcli-setup-agent/bedrock. No model key is on the user's machine. The OpenCode configuration turns on only the amazon-bedrock provider, points it at the proxy, and uses the config's model for title generation too. OpenCode gets a placeholder bearer token, and the user's AWS variables do not reach it. The proxy gives OpenCode its own secret path, which reaches only POST /model/... on the model relay, and it replaces the placeholder with the access token. ldcli now reads the config before it starts OpenCode. If the config is off or does not name a Bedrock model, setup stops and does not use the user's own provider. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
atornsii
added this pull request to stack #902
October 20, 2026 21:55
atornsii
marked this pull request as ready for review
October 20, 2026 21:56
managedModel and the AI SDK stream now use the same context. The context key is random, so with percentage targeting two contexts could pick different variations, and OpenCode could get a model that it did not enable.
The proxy now accepts only /model/{modelId}/{operation} on the model path, with no empty, . or .. segment. Before, a path such as /model/../../sdk/... could leave the model relay with the user's token.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…outing # Conflicts: # internal/setup/agent/opencode_config.go
…torns/agent-7-bedrock-routing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This sends the setup agent's model calls to a LaunchDarkly Bedrock relay in gonfalon. LaunchDarkly pays for the calls, and no model key is on the user's machine. It is the seventh agent PR, on top of #899.
How it works
ldcli-setup-agentconfig before it starts OpenCode, because OpenCode reads its configuration only once. The config must be on and must name a Bedrock model, such asBedrock.anthropic.claude-sonnet-4-6. If it does not, setup stops with an error. It does not use the user's own OpenCode provider.amazon-bedrock, withregion: us-east-1andendpointon the loopback proxy. It setsmodelandsmall_modelto the config's model, because OpenCode's default small model is a global inference profile (global.anthropic.claude-haiku-5-5).AWS_BEARER_TOKEN_BEDROCK=ldcli-placeholder, which takes priority over every AWS credential. The user's ownAWS_variables do not reach OpenCode.POST /model/..., and it reaches only/internal/ldcli-setup-agent/bedrockon gonfalon. OpenCode cannot reach the SDK routes. The proxy removes the bearer placeholder and addsLD-CLI-Token.OpenCode adds the US inference profile prefix itself, so the request is
POST /model/us.anthropic.claude-sonnet-4-6/converse-stream. The gonfalon side, which checks the token and signs the call for Bedrock, is launchdarkly/gonfalon#75426.Testing
/internal/ldcli-setup-agent/bedrock/model/us.anthropic.claude-sonnet-4-6/converse-streamwith the token header and without the bearer placeholder. The test skips if OpenCode is not installed.AWS_variables, and the refusal of a config that is off or that names another provider.amazon-bedrockis on.Stack
This is the seventh agent PR. Merge it after #894 to #899, which come after #877 (Go 1.26).
🤖 Generated with Claude Code
Note
Overview
Routes logged-in setup agent model traffic through LaunchDarkly-managed Amazon Bedrock on gonfalon instead of the user’s OpenCode providers. Setup now requires an enabled
ldcli-setup-agentAI Config with a Bedrock model before OpenCode starts; there is no fallback to the user’s own API keys or providers.OpenCode config (
openCodeConfig) optionally pinsamazon-bedrockas the only provider, setsmodel/small_model, and points Bedrock at a loopback proxy endpoint withus-east-1.startServercan injectAWS_BEARER_TOKEN_BEDROCK(placeholder) and stripsAWS_*from the child environment so OpenCode never uses local AWS credentials.The relay proxy gains a second secret
bedrockURLthat forwards only validatedPOST /model/{id}/{op}requests to/internal/ldcli-setup-agent/bedrock, strips the placeholder Authorization bearer, and still attachesLD-CLI-Token.AIConfigSource.managedModelresolves the Bedrock model and proxy endpoint using the samerunCtxas the AI SDK stream for consistent targeting.Tests cover managed OpenCode JSON, proxy routing/refusals, env stripping, managed-model errors, and an optional real OpenCode sandbox test.
Reviewed by Cursor Bugbot for commit e3c6c40. Bugbot is set up for automated code reviews on this repo. Configure here.